/****

    activequant - activestocks.eu

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

	
	contact  : contact@activestocks.eu
    homepage : http://www.activestocks.eu

****/
package org.activequant.dao.mock;

import org.activequant.core.domainmodel.account.Order;
import org.activequant.dao.IOrderDao;

/**
 * @TODO desc<br>
 * <br>
 * <b>History:</b><br>
 *  - [27.10.2007] Created (Erik Nijkamp)<br>
 *  - [27.10.2007] Replaced compareByExample(...) with T.equals() (Erik Nijkamp)<br>
 *
 *  @author Erik Nijkamp
 */
public class MockOrderDao extends MockDaoSupportBase<Order> implements IOrderDao {
	
	public MockOrderDao() {
		super(Order.class);
	}
	
	Long getId(Order t) {
		return t.getId();
	}
	
	void setId(Order t, Long id) {
		t.setId(id);
	}

	@Override
	protected boolean compareByExample(Order model, Order sample) {
		
		if(model.getOrderTimeStamp() != null) {
			if(!model.getOrderTimeStamp().equals(sample.getOrderTimeStamp())) {
				return false;
			}
		}
		
		if(model.getInstrumentSpecification().getSymbol() != null) {
			if(!model.getInstrumentSpecification().getSymbol().equals(sample.getInstrumentSpecification().getSymbol())) {
				return false;
			}
		}
		
		if(model.getInstrumentSpecification() != null) {
			if(!model.getInstrumentSpecification().equals(sample.getInstrumentSpecification())) {
				return false;
			}
		}
		
		if(model.getQuantity() != Order.NOT_SET) {
			if(model.getQuantity() != sample.getQuantity()) {
				return false;
			}
		}
		
		return true;
	}
}
